package com.zgs.mall.seckill.controller;

import com.zgs.common.utils.R;
import com.zgs.mall.seckill.service.SeckillService;
import com.zgs.mall.seckill.to.SecKillSkuRedisTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * 自定义受保护的资源
 */
@Controller
public class SeckillController {
    @Autowired
    SeckillService seckillService;
    //获取当前秒杀商品
    public R getCurrentSeckill(){
       List<SecKillSkuRedisTo> secKillSkuRedisTos= seckillService.getCurrentSeckill();

       return R.ok().setData(secKillSkuRedisTos);
    }
    //秒杀下单
    public R kill(String killId,String key,Integer num ){
        String orderSn=seckillService.kill(killId,key,num);
        return  R.ok().setData(orderSn);
    }

}
